<style>
    .import {
        opacity: 0;
        position: absolute;
        width: 69px;
        height: 38px;
        margin-left: -10px;
    }
    
    .layui-badge-rim {
        height: 20px;
        border-width: 1px;
        border-style: solid;
        background-color: #eef4f5;
        font: 14px Helvetica Neue, Helvetica, PingFang SC, Tahoma, Arial, sans-serif;
        color: #6e667d;
    }
    /*table tr {*/
    /*    height: 40px;*/
    /*    !* 其他样式 *!*/
    /*}*/
    
    #productPic_path>img {
        max-height: 350px;
        max-width: 700px;
    }
    
    .material-body {
        display: flex;
        height: 100% !important;
        padding: 0 15px 0 0 !important;
    }
    
    .material-nav {
        width: 102px;
        background: rgba(0, 0, 0, 0.01);
    }
    
    .material-nav .nav-cell {
        padding: 10px 5px 10px 10px;
        cursor: pointer;
        position: relative;
        display: flex;
        align-items: center;
    }
    
    .material-nav .nav-cell:hover {
        color: #333;
        transition: all 0.3s;
    }
    
    .material-nav .nav-cell.nav-active {
        color: #333;
    }
    
    .material-nav .nav-cell.nav-active::before {
        content: "";
        display: inline-block;
        height: 14px;
        width: 3px;
        background: #1ba70e;
        position: absolute;
        left: 0;
    }
    
    .material-body .body-left {
        width: 340px;
        height: 100%;
        overflow: hidden;
    }
    
    .body-left .layui-tab-content {
        height: 100%;
        padding: 0;
        flex: 1;
        border-right: 1px solid #e6e6e6;
    }
    
    .body-left .layui-tree {
        padding: 5px;
    }
    
    .body-left .layui-tab {
        height: 100%;
        color: #999;
        display: flex;
        overflow: auto;
    }
    
    .body-left .layui-tab-title li {
        padding: 0 10px;
    }
    
    .material-body .body-right {
        width: calc(100% - 355px);
        padding: 15px 0 15px 15px;
    }
    
    .layui-tree-emptyText {
        padding-top: 5px;
    }
    
    .body-right xm-select {
        min-height: 32px;
        line-height: 32px;
    }
    /*.body-right .layui-table-view {*/
    /*    margin: 0;*/
    /*}*/
    /*.layui-card-body .body-right .layui-table {*/
    /*    position: relative;*/
    /*    margin: 0;*/
    /*    height: 15px;*/
    /*}*/
</style>
<!-- 正文开始 -->
<div class="layui-fluid">
    <div class="layui-card">
        <div class="layui-card-body material-body">
            <!-- 头部操作栏 -->
            <div class="body-left">
                <div class="layui-tab layui-tab-brief">
                    <div class="material-nav" id="materialNav">
                    </div>
                    <div class="layui-tab-content material-tree" id="productTypeTree">
                    </div>
                </div>
            </div>
            <div class="body-right">
                <div class="layui-form lay-header" name="saleWorkOrderProcessingForm">
                    <div class="toolbar">
                        <div class="layui-form-item lay-query-content">
                            <div class="lay-query-box">
                                <div class="query-lt">
                                    <div class="layui-inline">
                                        <label class="layui-form-label">产品名称：</label>
                                        <div class="layui-input-inline">
                                            <input name="skuName" class="layui-input" type="text" placeholder="产品名称" autocomplete="off" />
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label">产品编码：</label>
                                        <div class="layui-input-inline">
                                            <input name="skuCode" class="layui-input" type="text" placeholder="产品编码" autocomplete="off" />
                                        </div>
                                    </div>
                                </div>
                                <div class="query-rt">
                                    <div class="layui-inline">
                                        <button class="layui-btn icon-btn" lay-filter="formSubSearchLog" lay-submit layui-form-keyDownSearch="true" type="button">
                                            查询
                                        </button>
                                        <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>
                                            重置
                                        </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="lay-btn-rows">
                        <div class="lay-btn-box">
                            <div class="lay-btn-lt">
                                <!--                            <a id="productBtnAdd" class="layui-btn icon-btn color-reseda">添加产品/物资信息</a>-->
                                <a id="productDetailBtnAdd" class="layui-btn icon-btn color-reseda">添加物资信息</a>
                                <button id="productDetailBtnImport" class="layui-btn icon-btn color-reseda">
                                    <input id="uploaderInput" type="file" name="file" class="import" accept=".xls,.xlsx" />导入
                                </button>
                            </div>
                            <div class="lay-btn-rt">
                                <button id="productDetailBtnTemplate" class="layui-btn icon-btn color-green">
                                    模板下载
                                </button>
                            </div>
                        </div>
                    </div>
                </div>
                <!-- 表格 -->
                <table class="layui-table img-table" id="productDetailTable" lay-filter="productDetailTable">
                </table>
            </div>
        </div>
    </div>
</div>

<style>
    form[lay-filter="productAddForm"] .tdInputOne>input {
        display: inline-block;
        width: 30%;
    }
    
    form[lay-filter="productAddForm"] .tdSelectOne>.layui-form-select {
        width: 19%;
        display: inline-block;
        margin-bottom: 5px;
        margin-right: 5px;
    }
    
    form[lay-filter="productAddForm"] .inputBorderNone {
        border-color: transparent;
        outline-color: transparent;
    }
    
    form[lay-filter="productAddForm"] .inputBorderNone:hover {
        border-color: transparent !important;
        outline-color: transparent;
    }
    
    form[lay-filter="productAddForm"] .inputBorderNone:focus {
        border-color: transparent !important;
        outline-color: transparent;
    }
    
    div[lay-id="productDetailTable"] .layui-table-body .layui-table-cell {
        height: 32px;
        line-height: 32px;
    }
    
    .layui-form-label.w-120 {
        width: 120px;
    }
</style>

<script type="text/html" id="materialNavTemplate">
    {{# layui.each(d, function(index, item){ }}
    <div class="nav-cell {{# if(item.isShow){ }}nav-active{{# } }}" data-value="{{item.labelValue}}">
        <span>{{item.labelName}}</span>
    </div>
    {{# }); }}
</script>
<!-- 表格操作列 -->
<script type="text/html" id="productDetailTableBar">
    <a class="layui-btn layui-btn-warm layui-btn-xs" lay-event="edit">编辑</a>
</script>

<!-- 表单弹窗 -->
<script type="text/html" id="productDetailForm">
    <form lay-filter="productDetailForm" class="layui-form open-form">
        <div class="open-model">
            <div class="open-auto">
                <input name="id" type="hidden" />
                <div class="layui-form-item">
                    <div class="layui-col-md4"></div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120"><span style="color: red">*</span>料号名称</label
            >
            <div class="layui-input-inline">
              <input
                name="skuName"
                id="skuName"
                class="layui-input borderNone"
                type="text"
                required
                lay-verify="required" />
            </div>
          </div>
          <div class="layui-col-md4">
            <label class="layui-form-label w-120"
              ><span style="color: red">*</span>料号</label
            >
            <div class="layui-input-inline">
              <input
                name="skuCode"
                id="skuCode"
                class="layui-input borderNone"
                type="text"
                required
                lay-verify="required" />
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-col-md4">
            <label class="layui-form-label w-120">国标条码</label>
                        <div class="layui-input-inline">
                            <input name="standardBarCode" id="standardBarCode" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">历史品名</label>
                        <div class="layui-input-inline">
                            <input name="historyProductName" id="historyProductName" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">历史料号</label>
                        <div class="layui-input-inline">
                            <input name="oldSkuCode" id="oldSkuCode" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120"><span style="color: red">*</span>规格码</label
            >
            <div class="layui-input-inline">
              <input
                name="skuSpec"
                id="skuSpec"
                class="layui-input borderNone"
                type="text"
                required
                lay-verify="required" />
            </div>
          </div>
          <div class="layui-col-md4">
            <label class="layui-form-label w-120"
              ><span style="color: red">*</span>物料类别性质</label
            >
            <div class="layui-input-inline">
              <select
                id="materialNature"
                name="materialNature"
                lay-filter="materialNature"
                required
                lay-verify="required"
                class="layui-input borderNone"></select>
            </div>
          </div>
          <div class="layui-col-md4">
            <label class="layui-form-label w-120"
              ><span style="color: red">*</span>所属类别</label
            >
            <div class="layui-input-inline">
              <select
                id="productTypeId"
                name="productTypeId"
                lay-filter="productTypeId"
                required
                lay-verify="required"
                class="layui-input borderNone"></select>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-col-md4">
            <label class="layui-form-label w-120"
              ><span style="color: red">*</span>物料分类</label
            >
            <div class="layui-input-inline">
              <select
                id="productCategoryId"
                name="productCategoryId"
                lay-filter="productCategoryId"
                requiredlay-verify="required"
                class="layui-input borderNone"></select>
            </div>
          </div>
          <div class="layui-col-md4">
            <label class="layui-form-label w-120">品牌</label>
                        <div class="layui-input-inline">
                            <select id="brandId" name="brandId" lay-filter="brandId" class="layui-input borderNone"></select>
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">库存计量方式</label>
                        <div class="layui-input-inline">
                            <select id="calculateWay" name="calculateWay" lay-filter="calculateWay" class="layui-input borderNone"></select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120"><span style="color: red">*</span>计量单位</label
            >
            <div class="layui-input-inline">
              <select
                id="unitId"
                name="unitId"
                lay-filter="unitId"
                required
                lay-verify="required"
                class="layui-input borderNone"></select>
            </div>
          </div>
          <div class="layui-col-md4">
            <label class="layui-form-label w-120"
              ><span style="color: red">*</span>基础单位换算率</label
            >
            <div class="layui-input-inline">
              <input
                name="baseUnitRate"
                id="baseUnitRate"
                class="layui-input borderNone"
                type="text"
                required
                lay-verify="required" />
            </div>
          </div>
          <div class="layui-col-md4">
            <label class="layui-form-label w-120"
              ><span style="color: red">*</span>基础单位</label
            >
            <div class="layui-input-inline">
              <select
                id="baseUnit"
                name="baseUnit"
                lay-filter="baseUnit"
                class="layui-input borderNone"
                required
                lay-verify="required"></select>
            </div>
          </div>
        </div>
        <div class="layui-form-item">
          <div class="layui-col-md4">
            <label class="layui-form-label w-120">计价币种</label>
                        <div class="layui-input-inline">
                            <select id="priceCurrency" name="priceCurrency" lay-filter="priceCurrency" class="layui-input borderNone"></select>
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">税率</label>
                        <div class="layui-input-inline">
                            <input name="taxRate" id="taxRate" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">是否自产产品</label>
                        <div class="layui-input-inline">
                            <select id="selfProductStatus" name="selfProductStatus" lay-filter="selfProductStatus" class="layui-input borderNone"></select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">产品性质</label>
                        <div class="layui-input-inline">
                            <select id="productNature" name="productNature" lay-filter="productNature" class="layui-input borderNone"></select>
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">是否委外生产</label>
                        <div class="layui-input-inline">
                            <select id="outsourceStatus" name="outsourceStatus" lay-filter="outsourceStatus" class="layui-input borderNone"></select>
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">工艺线路</label>
                        <div class="layui-input-inline">
                            <select id="productProcessLineId" name="productProcessLineId" lay-filter="productProcessLineId" class="layui-input borderNone"></select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">成本价</label>
                        <div class="layui-input-inline">
                            <input name="costPrice" id="costPrice" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">是否可以销售</label>
                        <div class="layui-input-inline">
                            <select id="sellStatus" name="sellStatus" lay-filter="sellStatus" class="layui-input borderNone"></select>
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">销售指导价</label>
                        <div class="layui-input-inline">
                            <input name="marketPrice" id="marketPrice" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">长度(mm)</label>
                        <div class="layui-input-inline">
                            <input name="length" id="length" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">宽度(mm)</label>
                        <div class="layui-input-inline">
                            <input name="width" id="width" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">高度(mm)</label>
                        <div class="layui-input-inline">
                            <input name="height" id="height" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">重量(克)</label>
                        <div class="layui-input-inline">
                            <input name="weight" id="weight" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">安全库存阈值</label>
                        <div class="layui-input-inline">
                            <input name="warningQuantity" id="warningQuantity" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">采购周期(天)</label>
                        <div class="layui-input-inline">
                            <input name="purchaseCycle" id="purchaseCycle" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">呆滞时长阈值(天)</label>
                        <div class="layui-input-inline">
                            <input name="lethargyThreshold" id="lethargyThreshold" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">质保期(天)</label>
                        <div class="layui-input-inline">
                            <input name="warrantyDay" id="warrantyDay" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">折旧时长(月)</label>
                        <div class="layui-input-inline">
                            <input name="depreciationTime" id="depreciationTime" class="layui-input borderNone" type="text" />
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">数据来源</label>
                        <div class="layui-input-inline">
                            <select id="dataSource" name="dataSource" lay-filter="dataSource" class="layui-input borderNone"></select>
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">是否一物一码</label>
                        <div class="layui-input-inline">
                            <select id="thingCodeStatus" name="thingCodeStatus" lay-filter="thingCodeStatus" class="layui-input borderNone"></select>
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">是否批次管理</label>
                        <div class="layui-input-inline">
                            <select id="batchStatus" name="batchStatus" lay-filter="batchStatus" class="layui-input borderNone"></select>
                        </div>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">是否先进先出</label>
                        <div class="layui-input-inline">
                            <select id="inoutStatus" name="inoutStatus" lay-filter="inoutStatus" class="layui-input borderNone"></select>
                        </div>
                    </div>
                    <div class="layui-col-md4">
                        <label class="layui-form-label w-120">产品属性</label>
                        <div class="layui-input-inline">
                            <select id="assemblyNature" name="assemblyNature" lay-filter="assemblyNature" class="layui-input borderNone"></select>
                        </div>
                    </div>
                </div>
            </div>
            <div class="layui-form-item text-right">
                <div class="right-btn">
                    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">
            取消
          </button>
                    <button class="layui-btn" lay-filter="productDetailSubmit" lay-submit>
            提交
          </button>
                </div>
            </div>
        </div>
    </form>
</script>

<!--添加产品-->
<script type="text/html" id="productAddForm">
    <!-- 表格 -->
    <table class="layui-table img-table" id="productDetailAddTable" lay-filter="productDetailAddTable">
    </table>
    <div class="layui-form-item text-right">
        <button class="layui-btn" type="button" lay-filter='productAddSubmit' lay-submit>提交</button>
        <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
    </div>
    </form>
</script>

<!--产品系列列表-->
<script type="text/html" id="productRangeList">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <form class="layui-form toolbar" lay-filter="productRangeList">
                    <div class="layui-form-item">
                        <div class="layui-inline">
                            <label class="layui-form-label">系列名称：</label>
                            <div class="layui-input-inline">
                                <input name="name" class="layui-input" type="text" />
                            </div>
                        </div>
                        <div class="layui-inline">
                            <button class="layui-btn icon-btn" lay-filter="productRangeListSearchLog" lay-submit type="button">
                搜索
              </button>
                            <button id="productRangeListAddClose" class="layui-btn icon-btn" type="button">
                确认选择
              </button>
                        </div>
                    </div>
                </form>

                <!-- 表格 -->
                <table class="layui-table" id="productRangeListTable" lay-filter="productRangeListTable"></table>

                <!--<div class="layui-form-item text-right">
                    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">取消</button>
                    <button class="layui-btn" lay-filter="productFormSubmit" lay-submit>保存</button>
                </div>-->
            </div>
        </div>
    </div>
</script>
<!-- 数据同步到云端表单弹窗 -->
<script type="text/html" id="syncSkuForm">
    <form lay-filter="synsSkuForm" class="layui-form model-form formBg" style="padding:20px;">
        <div class="layui-card-body">
            <input type="hidden" name="enterpriseCode" id="enterpriseCode" value="" />
            <div class="layui-row">
                <div class="layui-col-md4 conentStyle">
                    <div class="conentBg">
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品系列图片:</label>
                            <div class="layui-input-inline">
                                <input type="hidden" name="enterpriseItemPic" id="enterpriseItemPic" value="" />
                                <img src="" style="height: 135px;width: 135px" id="enterpriseItemPicImg" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品系列名称:</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseName" id="enterpriseName" class="layui-input borderNone" type="text" disabled />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品编码</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseProductCode" id="enterpriseProductCode" class="layui-input borderNone" type="text" disabled />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品类型</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseProductType" id="enterpriseProductType" class="layui-input borderNone" type="text" disabled />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品分类</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseProductCategory" id="enterpriseProductCategory" class="layui-input borderNone" type="text" disabled />
                            </div>
                        </div>
                        <!--<div class="layui-form-item">
                            <label class="layui-form-label w-120">企业产品扩展分类</label>
                            <div class="layui-input-inline">
                                <input name="enterpriseProductCategoryExt" id="enterpriseProductCategoryExt"
                                       class="layui-input borderNone" type="text" disabled/>
                            </div>
                        </div>-->
                    </div>
                </div>
                <div class="layui-col-md8 conentStyle">
                    <div class="conentBg">
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品系列图片:</label>
                            <div class="layui-input-inline">
                                <input type="hidden" name="pictureSynsInput" id="pictureSynsInput" value="" />
                                <img src="" style="height: 135px;width: 135px" id="pictureSyns" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品系列名称</label>
                            <div class="layui-input-inline">
                                <input id="platformName" placeholder="请输入平台产品系列" name="platformName" class="layui-input" lay-search lay-verify="required" />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品编码</label>
                            <div class="layui-input-inline">
                                <input name="platformProductCode" id="platformProductCode" class="layui-input" type="text" placeholder="请输入平台产品系列" disabled />
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品类型</label>
                            <div class="layui-input-inline">
                                <input id="platformProductTypeId" type="hidden" />
                                <select name="platformProductType" id="platformProductType" class="layui-input" type="text"></select>
                            </div>
                        </div>
                        <div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品分类</label>
                            <div class="layui-input-inline">
                                <select name="platformProductCategory" id="platformProductCategory" class="layui-input" type="text"></select>
                            </div>
                        </div>
                        <!-- <div class="layui-form-item">
                             <label class="layui-form-label w-120">平台产品扩展分类</label>
                             <div class="layui-input-inline">
                             <input name="platformProductCategoryExt" id="platformProductCategoryExt" class="layui-input"
                                    type="text" disabled/>
                             </div>
                         </div>-->
                        <!--<div class="layui-form-item">
                            <label class="layui-form-label w-120">平台产品属性</label>
                            <div class="layui-input-block">
                                <div class="layui-input-inline mr0" id="platformProductAttrHtml"
                                     name="platformProductAttrHtml"></div>
                                <div id="platformProductAttrValueHtml" name="platformProductAttrValueHtml"></div>
                            </div>
                        </div>-->
                    </div>
                </div>
            </div>

            <div class="layui-card-body">
                <input type="hidden" name="enterpriseCode" id="enterpriseDetailCode" value="" />
                <div class="layui-row">
                    <div class="layui-col-md4 conentStyle">
                        <div class="conentBg">
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品图片:</label>
                                <div class="layui-input-inline">
                                    <input type="hidden" name="enterpriseProductDetailPic" id="enterpriseProductDetailPic" value="" />
                                    <img src="" style="height: 80px;width: 80px" id="enterpriseProductDetailPicImg" />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品名称:</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseDetailName" id="enterpriseDetailName" class="layui-input borderNone" type="text" disabled />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品编码</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseProductDetailCode" id="enterpriseProductDetailCode" class="layui-input borderNone" type="text" disabled />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业品牌</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseProductDetailBrand" id="enterpriseProductDetailBrand" class="layui-input borderNone" type="text" disabled />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品单位</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseProductDetailUnit" id="enterpriseProductDetailUnit" class="layui-input borderNone" type="text" disabled />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品规格码</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseSkuSpecValueNames" id="enterpriseSkuSpecValueNames" class="layui-input borderNone" type="text" disabled />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品旧规格码</label>
                                <div class="layui-input-inline">
                                    <input name="enterpriseOldSpecCode" id="enterpriseOldSpecCode" class="layui-input borderNone" type="text" disabled />
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="layui-col-md8 conentStyle">
                        <div class="conentBg">
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">平台产品图片:</label>
                                <div class="layui-input-inline">
                                    <input type="hidden" name="platformProductDetailPic" id="platformProductDetailPic" value="" />
                                    <img src="" style="height: 80px;width: 80px" id="platformItemPicImg" />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">平台产品名称</label>
                                <div class="layui-input-inline">
                                    <input name="platformDetailName" id="platformDetailName" class="layui-input" type="text" placeholder="请输入产品名称" />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">平台产品编码</label>
                                <div class="layui-input-inline">
                                    <input name="platformProductDetailCode" id="platformProductDetailCode" class="layui-input" type="text" placeholder="请输入产品编码" disabled />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">平台品牌</label>
                                <div class="layui-input-inline">
                                    <select name="platformProductDetailBrand" id="platformProductDetailBrand" class="layui-input" type="text"></select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品单位</label>
                                <div class="layui-input-inline">
                                    <select name="platformProductDetailUnit" id="platformProductDetailUnit" class="layui-input" type="text"></select>
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品规格码</label>
                                <div class="layui-input-inline">
                                    <input name="platformSkuSpecValueNames" id="platformSkuSpecValueNames" class="layui-input borderNone" type="text" />
                                </div>
                            </div>
                            <div class="layui-form-item">
                                <label class="layui-form-label w-120">企业产品旧规格码</label>
                                <div class="layui-input-inline">
                                    <input name="platformOldSpecCode" id="platformOldSpecCode" class="layui-input borderNone" type="text" />
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="layui-form-item text-right">
                    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">
            取消
          </button>
                    <button class="layui-btn" lay-filter="syncSubmit" lay-submit>
            同步
          </button>
                </div>
            </div>
        </div>
    </form>
</script>
<!-- 产品系列弹窗 -->
<script type="text/html" id="productForm">
    <div class="layui-fluid">
        <div class="layui-card">
            <div class="layui-card-body">
                <!-- 头部操作栏 -->
                <div class="layui-form lay-header">
                    <div class="toolbar">
                        <div class="layui-form-item lay-query-content">
                            <div class="lay-query-box">
                                <div class="query-lt">
                                    <div class="layui-inline">
                                        <label class="layui-form-label w-auto">产品编号：</label>
                                        <div class="layui-input-inline">
                                            <input name="productCode" class="layui-input" type="text" placeholder="请输入产品编号" />
                                        </div>
                                    </div>
                                    <div class="layui-inline">
                                        <label class="layui-form-label w-auto">产品名称：</label>
                                        <div class="layui-input-inline">
                                            <input name="name" class="layui-input" type="text" placeholder="请产品名称" />
                                        </div>
                                    </div>
                                </div>
                                <div class="query-rt">
                                    <div class="layui-inline">
                                        <button class="layui-btn icon-btn color-green" lay-filter="formSubSearchLog" lay-submit>
                      查询
                    </button>
                                        <button class="layui-btn icon-btn color-white" lay-filter="resets" lay-submit>
                      重置
                    </button>
                                    </div>
                                </div>
                            </div>
                        </div>
                    </div>
                    <div class="lay-btn-rows">
                        <div class="lay-btn-box">
                            <div class="lay-btn-lt"></div>
                            <div class="lay-btn-rt"></div>
                        </div>
                    </div>
                </div>
                <!-- 表格 -->
                <table class="layui-table" id="productTable" lay-filter="productTable"></table>

                <div class="layui-form-item text-right">
                    <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">
            取消
          </button>
                    <button class="layui-btn" lay-filter="productSubmit" lay-submit>
            提交
          </button>
                </div>
            </div>
        </div>
    </div>
</script>

<!--单独修改图片-->
<!--imgModifyForm-->
<script type="text/html" id="imgModifyForm">
    <form lay-filter="imgModifyForm" class="layui-form model-form" style="padding: 5px 30px 0 30px;height: calc(100% - 5px);overflow: hidden;">
        <div class="open-details-box" style="height: calc(100% - 75px);">
            <div class="layui-row table-bor " style="margin-top: 15px;">
                <div class="layui-form-item">
                    <div id="productPic_path" class="uploadImgStyle"></div>
                    <div id="productPicBtn" class="layui-btn" style="float: left;">
                        <i class="layui-icon">&#xe681;</i>上传图片
                    </div>
                    <input name="productPic" type="hidden" class="layui-input" lay-verify="" id="productPic" />
                </div>
            </div>
        </div>
        <div class="layui-form-item text-right">
            <button class="layui-btn layui-btn-primary" type="button" ew-event="closeDialog">
        取消
      </button>
            <button class="layui-btn" lay-filter="imgModifyFormSubmit" lay-submit type="button">
        保存
      </button>
        </div>
    </form>
</script>

<!-- js部分 -->
<script>
    layui.use(
        ["layer", "form", "table", "admin", "upload", "tree", "laytpl"],
        function() {
            var $ = layui.jquery;
            var layer = layui.layer;
            var form = layui.form;
            var table = layui.table;
            var config = layui.config;
            var admin = layui.admin;
            var upload = layui.upload;
            var laytpl = layui.laytpl;
            var syncProductName = "";
            var syncProductId = 0;

            $("body").delegate(".checkImg", "click", function() {
                admin.previewImg(".checkImg");
            });

            // 获取类别性质
            admin.req(
                "enterprise/dict/admin/dictLabel/list", {
                    dictType: "sys_product_type_nature",
                    requestType: "purchase"
                },
                (res) => {
                    if (res.code == 200 && res.data.length > 0) {
                        res.data.forEach((item) => {
                            item.isShow = false;
                        });
                        res.data[0].isShow = true;
                        getProductType(res.data[0].labelValue);
                        laytpl(materialNavTemplate.innerHTML).render(
                            res.data,
                            function(html) {
                                $("#materialNav").html(html);
                                $("#materialNav .nav-cell").click(function() {
                                    let val = $(this).data("value");
                                    $(this)
                                        .addClass("nav-active")
                                        .siblings()
                                        .removeClass("nav-active");
                                    getProductType(val);
                                });
                            }
                        );
                    }
                }
            );

            //物料类型
            function getProductType(materialNature) {
                admin.req(
                    "enterprise/product/admin/productType/list", {
                        enterprise: 0,
                        limit: 99999,
                        materialNature: materialNature
                    },
                    (res) => {
                        if (res.code == 200) {
                            let treeList = res.data.filter((item) => {
                                return item.isDeleted;
                            });
                            initTree(treeList);
                            // loadSelectHtml(res.data, '请选择物料类型', 'productTypeId', 'name');
                        } else {
                            // loadSelectHtml([], '请选择物料类型', 'productTypeId', 'name')
                        }
                    }
                );
            }

            function initTree(data) {
                layui.tree.render({
                    elem: "#productTypeTree", //传入元素选择器
                    data: formatToTree(data, "-1"),
                    click: function(obj) {
                        insTb.reload({
                                where: {
                                    productTypeId: obj.data.id
                                },
                                page: {
                                    curr: 1
                                }
                            },
                            "data"
                        );
                    }
                });
            }

            function formatToTree(ary, pid, pidName = "parentId") {
                return ary
                    .filter((item) => item[pidName] === pid)
                    .map((item) => {
                        // 通过父节点ID递归查询所有子节点
                        item.children = formatToTree(ary, item.id);
                        item.label = item.name;
                        // item.spread = true
                        return item;
                    });
            }

            form.render("select");
            // 渲染表格
            var insTb = table.render({
                elem: "#productDetailTable",
                url: config.base + "enterprise/product/admin/productDetailWMS/list",
                where: {
                    categoryType: "production"
                },
                toolbar: true,
                defaultToolbar: ["filter"],
                page: true,
                limit: 10,
                limits: [10, 20, 30, 40, 50, 60, 70, 80],
                cellMinWidth: 100,
                cols: [
                    [{
                        type: "numbers",
                        title: "序号",
                        align: "center",
                        width: 60
                    }, {
                        field: "skuName",
                        align: "center",
                        width: 180,
                        templet: function(d) {
                            return '<span class="layui-badge-rim">' + d.skuName + "</span>";
                        },
                        title: "料号名称",
                        event: "imgClick"
                    }, {
                        field: "skuCode",
                        align: "center",
                        title: "料号",
                        width: 160
                    }, {
                        field: "skuSpec",
                        align: "center",
                        title: "规格码",
                        width: 160
                    }, {
                        field: "materialNatureName",
                        align: "center",
                        title: "类别性质",
                        width: 140
                    }, {
                        field: "productTypeName",
                        align: "center",
                        title: "所属类别",
                        width: 140
                    }, {
                        field: "mainUnitName",
                        align: "center",
                        title: "计量单位"
                    }, {
                        field: "mainUnitRate",
                        align: "center",
                        title: "换算率"
                    }, {
                        field: "baseUnitName",
                        align: "center",
                        title: "基础单位"
                    }, {
                        field: "createTime",
                        align: "center",
                        title: "创建时间",
                        width: 160
                    }, {
                        align: "center",
                        toolbar: "#productDetailTableBar",
                        title: "操作",
                        width: 100,
                        fixed: "right"
                    }]
                ]
            });

            // 工具条点击事件
            table.on("tool(productDetailTable)", function(obj) {
                var data = obj.data;
                if (obj.event === "edit") {
                    //修改
                    // showEditModel(data);
                    admin.formOpen({
                        area: "1200px",
                        offset: "65px",
                        title: "编辑物料明细",
                        path: "components/product/productDetailStorageForm.html",
                        success: function() {
                            parentData.data = data;
                        }
                    });
                } else if (obj.event === "imgClick") {
                    imgModify(data);
                } else if (obj.event === "del") {
                    // 删除
                    doDelete(obj);
                } else if (obj.event === "syncSku") {
                    // 同步
                    syncSku(obj);
                }
            });

            //监听排序
            table.on("sort(productDetailTable)", function(obj) {
                table.reload("productDetailTable", {
                    initSort: obj,
                    where: {
                        sort: obj.field,
                        order: obj.type
                    }
                });
            });

            // 搜索
            form.on("submit(formSubSearchLog)", function(data) {
                insTb.reload({
                        where: data.field,
                        page: {
                            curr: 1
                        }
                    },
                    "data"
                );
            });

            // 重置搜索
            form.on("submit(resets)", function(data) {
                insTb.reload({
                        where: admin.resetSearch(data.field),
                        page: {
                            curr: 1
                        }
                    },
                    "data"
                );
            });

            function imgModify(data) {
                admin.open({
                    type: 1,
                    area: ["900px", "500px"],
                    offset: "65px",
                    title: "修改图片",
                    content: $("#imgModifyForm").html(),
                    success: function() {
                        form.val("imgModifyForm", data);
                        $("#productPic_path").html(
                            '<img class="checkImg" style="max-height:350px; max-width: 700px" src="' +
                            data.productPic +
                            '"/>'
                        );
                        $("#productPicBtn").click(
                            uploadImg("productPicBtn", "productPic_path", "productPic")
                        );
                        form.on("submit(imgModifyFormSubmit)", function(d) {
                            layer.load(2);
                            d.field.id = data.id;
                            d.field.image = d.field.productPic;
                            admin.req(
                                "enterprise/product/admin/productDetail/update",
                                JSON.stringify(d.field),
                                function(res) {
                                    layer.closeAll("loading");
                                    if (res.code == 200) {
                                        layer.msg(res.msg, {
                                            icon: 1
                                        });
                                        table.reload("productDetailTable");
                                        layer.closeAll("page");
                                    } else {
                                        layer.msg(res.msg, {
                                            icon: 2
                                        });
                                    }
                                },
                                "PUT",
                                true,
                                "application/json; charset=utf-8"
                            );
                            return false;
                        });
                    }
                });
            }

            // 添加按钮点击事件
            $("#productDetailBtnAdd").click(function() {
                // showEditModel();
                admin.formOpen({
                    area: "1200px",
                    offset: "65px",
                    title: "添加物料明细",
                    path: "components/product/productDetailStorageForm.html",
                    success: function() {}
                });
            });

            // 显示编辑弹窗
            function showEditModel(data) {
                admin.open({
                    type: 1,
                    area: ["1200px", "92%"],
                    offset: "55px",
                    title: data ? "编辑物料明细" : "添加物料明细",
                    content: $("#productDetailForm").html(),
                    success: function() {
                        if (data) {
                            //获取物料明细
                            admin.reqSync(
                                "enterprise/product/admin/productDetailWMS/get?productDetailId=" +
                                data.id, {},
                                function(res) {
                                    layer.closeAll("loading");
                                    if (res.code == 200) {
                                        //货品
                                        admin.initDataSelect(
                                            "enterprise/product/admin/product/list", {
                                                limit: 9999
                                            },
                                            "productId",
                                            res.data.productId,
                                            "货品",
                                            null,
                                            null
                                        );
                                        //物料类别性质
                                        admin.getDictList(
                                            "materialNature",
                                            "sys_product_type_nature",
                                            res.data.materialNature,
                                            "物料类别性质"
                                        );
                                        //所属类别
                                        admin.initDataSelect(
                                            "enterprise/product/admin/productType/list", {
                                                limit: 9999
                                            },
                                            "productTypeId",
                                            res.data.productTypeId,
                                            "所属类别",
                                            null,
                                            null
                                        );
                                        //物料分类
                                        admin.initDataSelect(
                                            "enterprise/product/admin/productCategory/list", {
                                                limit: 9999
                                            },
                                            "productCategoryId",
                                            res.data.productCategoryId,
                                            "物料分类",
                                            null,
                                            null
                                        );
                                        //品牌
                                        admin.initDataSelect(
                                            "enterprise/product/admin/productBrand/list", {
                                                limit: 9999
                                            },
                                            "brandId",
                                            res.data.brandId,
                                            "品牌",
                                            null,
                                            null
                                        );
                                        //库存计量方式
                                        admin.getDictList(
                                            "calculateWay",
                                            "sys_product_detail_calculate_way",
                                            res.data.calculateWay,
                                            "库存计量方式"
                                        );
                                        //计量单位
                                        admin.getDictList(
                                            "unitId",
                                            "sys_product_detail_calculate_unit",
                                            res.data.unitId,
                                            "计量单位"
                                        );
                                        //基础单位
                                        admin.getDictList(
                                            "baseUnit",
                                            "sys_product_detail_base_unit",
                                            res.data.baseUnit,
                                            "基础单位"
                                        );
                                        //计价币种
                                        admin.getDictList(
                                            "priceCurrency",
                                            "sys_product_detail_price_currency",
                                            res.data.priceCurrency,
                                            "计价币种"
                                        );
                                        //是否自产产品
                                        admin.getDictList(
                                            "selfProductStatus",
                                            "sys_yes_no",
                                            res.data.selfProductStatus,
                                            "是否自产产品"
                                        );
                                        //产品性质

                                        admin.getDictList(
                                            "productNature",
                                            "product_nature",
                                            res.data.productNature,
                                            "产品性质"
                                        );
                                        //是否委外生产
                                        admin.getDictList(
                                            "outsourceStatus",
                                            "sys_yes_no",
                                            res.data.outsourceStatus,
                                            "是否委外生产"
                                        );
                                        //工艺线路
                                        admin.initDataSelect(
                                            "enterprise/product/admin/processLineTemplate/list", {
                                                limit: 99999
                                            },
                                            "productProcessLineId",
                                            res.data.productProcessLineId,
                                            "工艺线路",
                                            null,
                                            null
                                        );
                                        //是否可以销售
                                        admin.getDictList(
                                            "sellStatus",
                                            "sys_yes_no",
                                            res.data.sellStatus,
                                            "是否可以销售"
                                        );
                                        //数据来源
                                        admin.getDictList(
                                            "dataSource",
                                            "sys_product_detail_data_source",
                                            res.data.dataSource,
                                            "数据来源"
                                        );
                                        //是否一物一码
                                        admin.getDictList(
                                            "thingCodeStatus",
                                            "sys_yes_no",
                                            res.data.thingCodeStatus,
                                            "是否一物一码"
                                        );
                                        //是否批次管理
                                        admin.getDictList(
                                            "batchStatus",
                                            "sys_yes_no",
                                            res.data.batchStatus,
                                            "是否批次管理"
                                        );
                                        //是否先进先出
                                        admin.getDictList(
                                            "inoutStatus",
                                            "sys_yes_no",
                                            res.data.inoutStatus,
                                            "是否先进先出"
                                        );
                                        //产品属性
                                        admin.getDictList(
                                            "assemblyNature",
                                            "product_assembly_nature",
                                            res.data.assemblyNature,
                                            "产品属性"
                                        );
                                        form.val("productDetailForm", res.data);
                                    } else {
                                        layer.msg(res.msg, {
                                            icon: 2
                                        });
                                    }
                                },
                                "GET"
                            );
                        } else {
                            //货品
                            admin.initDataSelect(
                                "enterprise/product/admin/product/list", {
                                    limit: 9999
                                },
                                "productId",
                                null,
                                "货品",
                                null,
                                null
                            );
                            //物料类别性质
                            admin.getDictList(
                                "materialNature",
                                "sys_product_type_nature",
                                null,
                                "物料类别性质"
                            );
                            //所属类别
                            admin.initDataSelect(
                                "enterprise/product/admin/productType/list", {
                                    limit: 9999
                                },
                                "productTypeId",
                                null,
                                "所属类别",
                                null,
                                null
                            );
                            //物料分类
                            admin.initDataSelect(
                                "enterprise/product/admin/productCategory/list", {
                                    limit: 9999
                                },
                                "productCategoryId",
                                null,
                                "物料分类",
                                null,
                                null
                            );
                            //品牌
                            admin.initDataSelect(
                                "enterprise/product/admin/productBrand/list", {
                                    limit: 9999
                                },
                                "brandId",
                                null,
                                "品牌",
                                null,
                                null
                            );
                            //库存计量方式
                            admin.getDictList(
                                "calculateWay",
                                "sys_product_detail_calculate_way",
                                null,
                                "库存计量方式"
                            );
                            //计量单位
                            admin.getDictList(
                                "unitId",
                                "sys_product_detail_calculate_unit",
                                null,
                                "计量单位"
                            );
                            //基础单位
                            admin.getDictList(
                                "baseUnit",
                                "sys_product_detail_base_unit",
                                null,
                                "基础单位"
                            );
                            //计价币种
                            admin.getDictList(
                                "priceCurrency",
                                "sys_product_detail_price_currency",
                                null,
                                "计价币种"
                            );
                            //是否自产产品
                            admin.getDictList(
                                "selfProductStatus",
                                "sys_yes_no",
                                null,
                                "是否自产产品"
                            );
                            //产品性质
                            admin.getDictList(
                                "productNature",
                                "product_nature",
                                null,
                                "产品性质"
                            );
                            //是否委外生产
                            admin.getDictList(
                                "outsourceStatus",
                                "sys_yes_no",
                                null,
                                "是否委外生产"
                            );
                            //工艺线路
                            admin.initDataSelect(
                                "enterprise/product/admin/processLineTemplate/list", {
                                    limit: 99999
                                },
                                "productProcessLineId",
                                null,
                                "工艺线路",
                                null,
                                null
                            );
                            //是否可以销售
                            admin.getDictList(
                                "sellStatus",
                                "sys_yes_no",
                                null,
                                "是否可以销售"
                            );
                            //数据来源
                            admin.getDictList(
                                "dataSource",
                                "sys_product_detail_data_source",
                                null,
                                "数据来源"
                            );
                            //是否一物一码
                            admin.getDictList(
                                "thingCodeStatus",
                                "sys_yes_no",
                                null,
                                "是否一物一码"
                            );
                            //是否批次管理
                            admin.getDictList(
                                "batchStatus",
                                "sys_yes_no",
                                null,
                                "是否批次管理"
                            );
                            //是否先进先出
                            admin.getDictList(
                                "inoutStatus",
                                "sys_yes_no",
                                null,
                                "是否先进先出"
                            );
                            //产品属性
                            admin.getDictList(
                                "assemblyNature",
                                "product_assembly_nature",
                                null,
                                "产品属性"
                            );
                        }

                        // 表单提交事件
                        form.on("submit(productDetailSubmit)", function(d) {
                            admin.req(
                                data ?
                                "enterprise/product/admin/productDetail/update" :
                                "enterprise/product/admin/productDetail/add",
                                JSON.stringify(d.field),
                                function(res) {
                                    layer.closeAll("loading");
                                    if (res.code == 200) {
                                        layer.msg(res.msg, {
                                            icon: 1
                                        });
                                        table.reload("productDetailTable");
                                        layer.closeAll("page");
                                    } else {
                                        layer.msg(res.msg, {
                                            icon: 2
                                        });
                                    }
                                },
                                data ? "PUT" : "POST",
                                true,
                                "application/json; charset=utf-8"
                            );
                            return false;
                        });
                    }
                });
            }

            //查询企业信息
            var enterpriseInfo;
            admin.req(
                "enterprise/system/admin/enterpricceId/getEnterpricceIdVO", {},
                function(res) {
                    enterpriseInfo = res.data;
                },
                "get",
                false
            );

            function syncSku(obj) {
                admin.open({
                    type: 1,
                    area: ["80%", "80%"],
                    offset: "65px",
                    title: "同步至云端",
                    content: $("#syncSkuForm").html(),
                    success: function() {
                        var sync = false;
                        var productData = null;
                        //获取企业产品
                        admin.reqSync(
                            "enterprise/product/admin/productDetailWMS/syncList?skuCode=" +
                            obj.data.skuCode, {},
                            function(res) {
                                layer.closeAll("loading");
                                if (res.code == 200) {
                                    $("#enterpriseItemPicImg").attr("src", res.data.picture);
                                    $("#enterpriseName").val(res.data.name);
                                    $("#enterpriseProductCode").val(res.data.productCode);
                                    $("#enterpriseProductType").val(res.data.productType);
                                    $("#enterpriseProductCategory").val(res.data.productCategory);
                                    $("#enterpriseProductCategoryExt").val(
                                        res.data.enterpriseProductCategoryExt
                                    );
                                    $("#enterpriseDetailName").val(
                                        res.data.productDetail.productName
                                    );
                                    $("#enterpriseProductDetailPicImg").attr(
                                        "src",
                                        res.data.productDetail.productPic
                                    );
                                    $("#enterpriseProductDetailCode").val(
                                        res.data.productDetail.skuCode
                                    );
                                    $("#enterpriseProductDetailBrand").val(
                                        res.data.productDetail.brandName
                                    );
                                    $("#enterpriseProductDetailUnit").val(
                                        res.data.productDetail.unitName
                                    );
                                    $("#enterpriseSkuSpecValueNames").val(
                                        res.data.productDetail.skuSpecValueNames
                                    );
                                    $("#enterpriseOldSpecCode").val(
                                        res.data.productDetail.oldSpecCode
                                    );

                                    $("#pictureSyns").attr("src", res.data.picture);
                                    $("#platformProductCode").val(
                                        enterpriseInfo.enterpriseCode + "_" + res.data.productCode
                                    );
                                    $("#platformName").val(res.data.name);
                                    $("#platformItemPicImg").attr(
                                        "src",
                                        res.data.productDetail.productPic
                                    );
                                    $("#platformProductDetailCode").val(
                                        enterpriseInfo.enterpriseCode +
                                        "_" +
                                        res.data.productDetail.skuCode
                                    );
                                    $("#platformDetailName").val(
                                        res.data.productDetail.productName
                                    );
                                    $("#platformSkuSpecValueNames").val(
                                        res.data.productDetail.skuSpecValueNames
                                    );
                                    $("#platformOldSpecCode").val(
                                        res.data.productDetail.oldSpecCode
                                    );
                                    productData = res.data;
                                    //form.render();
                                } else {
                                    layer.msg(res.msg, {
                                        icon: 2
                                    });
                                }
                            },
                            "GET"
                        );
                        /*//获取平台产品
                                                                                                                                                                                                                                                                                                        $("#platformName").click(function () {
                                                                                                                                                                                                                                                                                                           var platformForm = admin.open({
                                                                                                                                                                                                                                                                                                                type: 1,
                                                                                                                                                                                                                                                                                                                area: ['80%', '80%'],
                                                                                                                                                                                                                                                                                                                offset: '65px',
                                                                                                                                                                                                                                                                                                                title: '同步至云端',
                                                                                                                                                                                                                                                                                                                content: $('#productForm').html(),
                                                                                                                                                                                                                                                                                                                success: function () {
                                                                                                                                                                                                                                                                                                                    // 渲染表格
                                                                                                                                                                                                                                                                                                                    var insTb = table.render({
                                                                                                                                                                                                                                                                                                                        elem: '#productTable',
                                                                                                                                                                                                                                                                                                                        url: config.base + 'enterprise/product/admin/productSeries/platformProductSeries',
                                                                                                                                                                                                                                                                                                                        page: true,
                                                                                                                                                                                                                                                                                                                        where: {
                                                                                                                                                                                                                                                                                                                            "dataSourceType": 0,
                                                                                                                                                                                                                                                                                                                            "type": 0
                                                                                                                                                                                                                                                                                                                        },
                                                                                                                                                                                                                                                                                                                        cellMinWidth: 100,
                                                                                                                                                                                                                                                                                                                        cols: [[
                                                                                                                                                                                                                                                                                                                            {type: 'radio'}
                                                                                                                                                                                                                                                                                                                            , {
                                                                                                                                                                                                                                                                                                                                field: 'picture', sort: true, title: '产品图片'
                                                                                                                                                                                                                                                                                                                                , templet: '<div><img src="{{ d.picture}}"></div>'
                                                                                                                                                                                                                                                                                                                            }
                                                                                                                                                                                                                                                                                                                            , {field: 'name', sort: true, title: '产品名称'}
                                                                                                                                                                                                                                                                                                                            , {field: 'productCode', sort: true, title: '产品编码'}
                                                                                                                                                                                                                                                                                                                            , {field: 'productTypeName', sort: true, title: '产品类型'}
                                                                                                                                                                                                                                                                                                                            , {field: 'productCategoryName', sort: true, title: '产品分类'}
                                                                                                                                                                                                                                                                                                                            , {field: 'keyword', sort: true, title: '关键词'}
                                                                                                                                                                                                                                                                                                                            , {field: 'pricingMethodDesc', sort: true, title: '计价方式'}
                                                                                                                                                                                                                                                                                                                            , {field: 'unitName', sort: true, title: '单位'}
                                                                                                                                                                                                                                                                                                                            , {field: 'createTime', sort: true, title: '创建时间'}
                                                                                                                                                                                                                                                                                                                            , {field: 'creatorName', sort: true, title: '创建人'}
                                                                                                                                                                                                                                                                                                                            , {field: 'isSynsDes', sort: true, title: '是否同步'}
                                                                                                                                                                                                                                                                                                                            , {field: 'synsTime', sort: true, title: '同步时间'}
                                                                                                                                                                                                                                                                                                                            , {align: 'center', toolbar: '#productTableBar', title: '操作', width: 300}
                                                                                                                                                                                                                                                                                                                        ]],
                                                                                                                                                                                                                                                                                                                        done: function (res, curr, count) {
                                                                                                                                                                                                                                                                                                                            //移除按钮
                                                                                                                                                                                                                                                                                                                            // var menuButton = config.getMenuButton(location.hash);
                                                                                                                                                                                                                                                                                                                            // if (menuButton.indexOf("搜索") == -1) {
                                                                                                                                                                                                                                                                                                                            //     $('.layui-form.toolbar').remove();
                                                                                                                                                                                                                                                                                                                            // }
                                                                                                                                                                                                                                                                                                                            // if (menuButton.indexOf("修改") == -1) {
                                                                                                                                                                                                                                                                                                                            //     $("[lay-event='edit']").remove();
                                                                                                                                                                                                                                                                                                                            // }
                                                                                                                                                                                                                                                                                                                            // if (menuButton.indexOf("删除") == -1) {
                                                                                                                                                                                                                                                                                                                            //     $("[lay-event='del']").remove();
                                                                                                                                                                                                                                                                                                                            // }
                                                                                                                                                                                                                                                                                                                        }
                                                                                                                                                                                                                                                                                                                    });
                                                                                                                                                                                                                                                                                                                    // 搜索
                                                                                                                                                                                                                                                                                                                    form.on('submit(formSubSearchLog)', function (data) {
                                                                                                                                                                                                                                                                                                                        insTb.reload({where: data.field, page: {curr: 1}}, 'data');
                                                                                                                                                                                                                                                                                                                    });
                                                                                                                                                                                                                                                                                                                    form.on('submit(productSubmit)', function (data) {
                                                                                                                                                                                                                                                                                                                        var selectData = layui.table.checkStatus('productTable').data;
                                                                                                                                                                                                                                                                                                                        console.log(selectData)
                                                                                                                                                                                                                                                                                                                        $("#platformName").val(selectData[0].name);
                                                                                                                                                                                                                                                                                                                        $("#platformNameId").val(selectData[0].id);
                                                                                                                                                                                                                                                                                                                        $("#platformProductCode").val(selectData[0].productCode);
                                                                                                                                                                                                                                                                                                                        $("#platformProductType").val(selectData[0].productTypeName);
                                                                                                                                                                                                                                                                                                                        $("#platformProductTypeId").val(selectData[0].productTypeId);
                                                                                                                                                                                                                                                                                                                        $("#platformProductCategory").val(selectData[0].productCategoryName);
                                                                                                                                                                                                                                                                                                                        $("#platformProductCategoryId").val(selectData[0].productCategoryId);
                                                                                                                                                                                                                                                                                                                        layer.close(platformForm);
                                                                                                                                                                                                                                                                                                                    });

                                                                                                                                                                                                                                                                                                                }
                                                                                                                                                                                                                                                                                                            })
                                                                                                                                                                                                                                                                                                        })*/

                        //获取平台产品类型
                        admin.req(
                            "enterprise/product/admin/productType/platformProductTypeList", {},
                            function(res) {
                                if (res.code === 200) {
                                    loadSelectHtml(
                                        res.data,
                                        "平台产品类型",
                                        "platformProductType",
                                        1,
                                        "synsSkuForm"
                                    );
                                } else {
                                    loadSelectHtml(
                                        [],
                                        "平台产品类型",
                                        "platformProductType",
                                        1,
                                        "synsSkuForm"
                                    );
                                }
                            },
                            "GET"
                        );

                        //获取平台产品分类
                        admin.req(
                            "enterprise/product/admin/productCategory/platformProductCategoryList", {},
                            function(res) {
                                if (res.code === 200) {
                                    loadSelectHtml(
                                        res.data,
                                        "平台产品分类",
                                        "platformProductCategory",
                                        1,
                                        "synsSkuForm"
                                    );
                                } else {
                                    loadSelectHtml(
                                        [],
                                        "平台产品分类",
                                        "platformProductCategory",
                                        1,
                                        "synsSkuForm"
                                    );
                                }
                            },
                            "GET"
                        );

                        //获取平台品牌
                        admin.req(
                            "enterprise/product/admin/productBrand/platformList", {},
                            function(res) {
                                if (res.code === 200) {
                                    loadSelectHtml(
                                        res.data,
                                        "平台品牌",
                                        "platformProductDetailBrand",
                                        1,
                                        "synsSkuForm"
                                    );
                                } else {
                                    loadSelectHtml(
                                        [],
                                        "平台品牌",
                                        "platformProductDetailBrand",
                                        1,
                                        "synsSkuForm"
                                    );
                                }
                            },
                            "GET"
                        );

                        //获取平台产品单位
                        admin.req(
                            "enterprise/product/admin/productUnit/platformProductUnitList", {},
                            function(res) {
                                if (res.code === 200) {
                                    loadSelectHtml(
                                        res.data,
                                        "平台产品分类",
                                        "platformProductDetailUnit",
                                        1,
                                        "synsSkuForm"
                                    );
                                } else {
                                    loadSelectHtml(
                                        [],
                                        "平台产品分类",
                                        "platformProductDetailUnit",
                                        1,
                                        "synsSkuForm"
                                    );
                                }
                            },
                            "GET"
                        );

                        /* admin.req('enterprise/product/admin/productDetailWMS/syncPlatformList', JSON.stringify(productData)  , function (res) {
                                                                                                                                                                                                                                                                                                             layer.closeAll('loading');
                                                                                                                                                                                                                                                                                                             if (res.code == 200) {
                                                                                                                                                                                                                                                                                                                 $("#pictureSyns").attr("src", res.data.picture);
                                                                                                                                                                                                                                                                                                                 $("#platformName").val(res.data.name)
                                                                                                                                                                                                                                                                                                                 $("#platformProductCode").val(res.data.productCode)
                                                                                                                                                                                                                                                                                                                 $("#platformProductType").val(res.data.productType)
                                                                                                                                                                                                                                                                                                                 $("#platformProductCategory").val(res.data.productCategory)
                                                                                                                                                                                                                                                                                                                 $("#platformProductCategoryExt").val(res.data.enterpriseProductCategoryExt)
                                                                                                                                                                                                                                                                                                                 $("#platformDetailName").val(res.data.productDetail.productName)
                                                                                                                                                                                                                                                                                                                 $("#platformItemPicImg").attr("src",res.data.productDetail.productPic)
                                                                                                                                                                                                                                                                                                                 $("#platformProductDetailCode").val(res.data.productDetail.skuCode)
                                                                                                                                                                                                                                                                                                                 $("#platformProductDetailBrand").val(res.data.productDetail.brandName)
                                                                                                                                                                                                                                                                                                                 $("#platformProductDetailUnit").val(res.data.productDetail.unitName)
                                                                                                                                                                                                                                                                                                                 sync = true;
                                                                                                                                                                                                                                                                                                                 //form.render();
                                                                                                                                                                                                                                                                                                             } else {
                                                                                                                                                                                                                                                                                                                 layer.msg(res.msg, {icon: 2});
                                                                                                                                                                                                                                                                                                             }
                                                                                                                                                                                                                                                                                                         }, 'POST',true, 'application/json; charset=utf-8');*/

                        form.on("submit(syncSubmit)", function(data) {
                            productData.picture = $("#pictureSyns").val();
                            productData.productCode = $("#platformProductCode").val();
                            productData.name = $("#platformName").val();
                            productData.productTypeId = $("#platformProductType").val();
                            productData.productCategoryId = $(
                                "#platformProductCategory"
                            ).val();
                            productData.productDetail.productPic = $(
                                "#platformItemPicImg"
                            ).val();
                            productData.productDetail.skuCode = $(
                                "#platformProductDetailCode"
                            ).val();
                            productData.productDetail.skuName = $(
                                "#platformDetailName"
                            ).val();
                            productData.productDetail.skuSpecValueNames = $(
                                "#platformSkuSpecValueNames"
                            ).val();
                            productData.productDetail.oldSpecCode = $(
                                "#platformOldSpecCode"
                            ).val();
                            productData.productDetail.brandId = $(
                                "#platformProductDetailBrand"
                            ).val();
                            productData.productDetail.unitId = $(
                                "#platformProductDetailUnit"
                            ).val();
                            admin.req(
                                "enterprise/product/admin/productDetailWMS/syncProduct",
                                JSON.stringify(productData),
                                function(res) {
                                    if (res.code == 200) {
                                        layer.msg(res.msg, {
                                            icon: 1
                                        });
                                    } else {
                                        layer.msg(res.msg, {
                                            icon: 2
                                        });
                                    }
                                },
                                "POST",
                                true,
                                "application/json; charset=utf-8"
                            );
                            /* layer.msg("不允许非法同步", {icon: 2});*/
                            return false;
                        });
                    }
                });
            }

            // 删除
            function doDelete(obj) {
                layer.confirm(
                    "确定要删除吗？", {
                        offset: "65px",
                        skin: "layui-layer-admin"
                    },
                    function(i) {
                        layer.close(i);
                        layer.load(2);
                        admin.req(
                            "enterprise/product/admin/productDetail/" + obj.data.id, {},
                            function(res) {
                                layer.closeAll("loading");
                                if (res.code == 200) {
                                    layer.msg(res.msg, {
                                        icon: 1
                                    });
                                    obj.del();
                                } else {
                                    layer.msg(res.msg, {
                                        icon: 2
                                    });
                                }
                            },
                            "DELETE"
                        );
                    }
                );
            }

            // 导出excel
            $("#productDetailBtnExport").click(function() {
                var checkRows = table.checkStatus("productDetailTable");
                if (checkRows.data.length == 0) {
                    layer.msg("请选择要导出的数据", {
                        icon: 2
                    });
                } else {
                    table.exportFile(insTb.config.id, checkRows.data, "xls");
                }
            });

            // 添加产品/物资信息按钮点击事件
            $("#productBtnAdd").click(function() {
                showAddProduct();
            });

            //添加产品/物资信息弹窗
            function showAddProduct() {
                admin.open({
                    type: 1,
                    area: ["97%", "93%"],
                    offset: ["35px", "35px"],
                    title: "添加产品/物资信息",
                    content: $("#productAddForm").html(),
                    success: function() {
                        //字典数据
                        var dictDataList;
                        admin.req(
                            "enterprise/dict/admin/dictLabel/select", {},
                            function(res) {
                                dictDataList = res.data;
                            },
                            "get",
                            false
                        );

                        //物料类别性质
                        var materialNatureList = [];
                        dictDataList.forEach((item, index) => {
                            if (item.dictType === "sys_product_type_nature") {
                                materialNatureList.push(item);
                            }
                        });

                        //所属类别
                        var productTypeList;
                        admin.req(
                            "enterprise/product/admin/productType/list", {
                                limit: 9999
                            },
                            function(res) {
                                productTypeList = res.data;
                            },
                            "get",
                            false
                        );

                        //品牌
                        var productBrandList;
                        admin.req(
                            "enterprise/product/admin/productBrand/list", {
                                limit: 9999
                            },
                            function(res) {
                                productBrandList = res.data;
                            },
                            "get",
                            false
                        );

                        //库存计量方式
                        var calculateWayList = [];
                        dictDataList.forEach((item, index) => {
                            if (item.dictType === "sys_product_detail_calculate_way") {
                                calculateWayList.push(item);
                            }
                        });

                        //库存计量方式
                        var calculateWayList = [];
                        dictDataList.forEach((item, index) => {
                            if (item.dictType === "sys_product_detail_calculate_way") {
                                calculateWayList.push(item);
                            }
                        });
                        //计量单位
                        var calculateUnitList = [];
                        dictDataList.forEach((item, index) => {
                            if (item.dictType === "sys_product_detail_calculate_unit") {
                                calculateUnitList.push(item);
                            }
                        });
                        //基础单位
                        var baseUnitList = [];
                        dictDataList.forEach((item, index) => {
                            if (item.dictType === "sys_product_detail_base_unit") {
                                baseUnitList.push(item);
                            }
                        });
                        //基础单位
                        var baseUnitList = [];
                        dictDataList.forEach((item, index) => {
                            if (item.dictType === "sys_product_detail_base_unit") {
                                baseUnitList.push(item);
                            }
                        });
                        //计价币种
                        var priceCurrencyList = [];
                        dictDataList.forEach((item, index) => {
                            if (item.dictType === "sys_product_detail_price_currency") {
                                priceCurrencyList.push(item);
                            }
                        });
                        //是否
                        var yesNoList = [];
                        dictDataList.forEach((item, index) => {
                            if (item.dictType === "sys_yes_no") {
                                yesNoList.push(item);
                            }
                        });

                        table.render({
                            elem: "#productDetailAddTable",
                            url: config.base +
                                "enterprise/product/admin/productDetail/initAddData",
                            page: false,
                            cellMinWidth: 120,
                            cols: [
                                [{
                                    field: "productName",
                                    align: "center",
                                    title: "品名",
                                    edit: "text"
                                }, {
                                    field: "materialNumber",
                                    align: "center",
                                    title: "料号",
                                    edit: "text"
                                }, {
                                    field: "enterpriseShipmentNumber",
                                    align: "center",
                                    title: "企业货号",
                                    edit: "text"
                                }, {
                                    field: "standardBarCode",
                                    align: "center",
                                    title: "国标条码",
                                    edit: "text"
                                }, {
                                    field: "historyProductName",
                                    align: "center",
                                    title: "历史品名",
                                    edit: "text"
                                }, {
                                    field: "historyMaterialNumber",
                                    align: "center",
                                    title: "历史料号",
                                    edit: "text"
                                }, {
                                    field: "specCode",
                                    align: "center",
                                    title: "规格码",
                                    edit: "text"
                                }, {
                                    field: "materialNature",
                                    align: "center",
                                    title: "物料类别性质",
                                    width: 200,
                                    templet: function(d) {
                                        let selectHtml =
                                            '<select lay-filter="materialNature-select" name="materialNature">';
                                        selectHtml +=
                                            '<option value="" >请选择物料类别性质</option>';
                                        layui.each(materialNatureList, function(index, item) {
                                            selectHtml +=
                                                '<option value="' +
                                                item.labelValue +
                                                '" >' +
                                                item.labelName +
                                                "</option>";
                                        });
                                        selectHtml += "</select>";
                                        return selectHtml;
                                    }
                                }, {
                                    field: "productType",
                                    align: "center",
                                    title: "所属类别",
                                    width: 200,
                                    templet: (d) => {
                                        let selectHtml =
                                            '<select lay-filter="productType-select" name="productType">';
                                        selectHtml += '<option value="" >请选择所属类别</option>';
                                        layui.each(productTypeList, function(index, item) {
                                            selectHtml +=
                                                '<option value="' +
                                                item.id +
                                                '" >' +
                                                item.name +
                                                "</option>";
                                        });
                                        selectHtml += "</select>";
                                        return selectHtml;
                                    }
                                }, {
                                    field: "productBrand",
                                    align: "center",
                                    title: "品牌",
                                    width: 180,
                                    templet: function() {
                                        let selectHtml =
                                            '<select lay-filter="productBrand-select" name="productBrand">';
                                        selectHtml += '<option value="" >请选择品牌</option>';
                                        layui.each(productBrandList, function(index, item) {
                                            selectHtml +=
                                                '<option value="' +
                                                item.id +
                                                '" >' +
                                                item.name +
                                                "</option>";
                                        });
                                        selectHtml += "</select>";
                                        return selectHtml;
                                    }
                                }, {
                                    field: "calculateWay",
                                    align: "center",
                                    title: "库存计量方式",
                                    width: 200,
                                    templet: function(d) {
                                        let selectHtml =
                                            '<select lay-filter="calculateWay-select" name="calculateWay">';
                                        selectHtml +=
                                            '<option value="" >请选择库存计量方式</option>';
                                        layui.each(calculateWayList, function(index, item) {
                                            selectHtml +=
                                                '<option value="' +
                                                item.labelValue +
                                                '" >' +
                                                item.labelName +
                                                "</option>";
                                        });
                                        selectHtml += "</select>";
                                        return selectHtml;
                                    }
                                }, {
                                    field: "calculateUnit",
                                    align: "center",
                                    title: "计量单位",
                                    width: 200,
                                    templet: function(d) {
                                        let selectHtml =
                                            '<select lay-filter="calculateUnit-select" name="calculateUnit">';
                                        selectHtml += '<option value="" >请选择计量单位</option>';
                                        layui.each(calculateUnitList, function(index, item) {
                                            selectHtml +=
                                                '<option value="' +
                                                item.labelValue +
                                                '" >' +
                                                item.labelName +
                                                "</option>";
                                        });
                                        selectHtml += "</select>";
                                        return selectHtml;
                                    }
                                }, {
                                    field: "baseUnitRate",
                                    align: "center",
                                    title: "基础单位换算率",
                                    width: 140,
                                    edit: "text"
                                }, {
                                    field: "quantity",
                                    align: "center",
                                    title: "库存数",
                                    edit: "text"
                                }, {
                                    field: "baseUnit",
                                    align: "center",
                                    title: "基础单位",
                                    width: 200,
                                    templet: function(d) {
                                        let selectHtml =
                                            '<select lay-filter="baseUnit-select" name="baseUnit">';
                                        selectHtml += '<option value="" >请选择基础单位</option>';
                                        layui.each(baseUnitList, function(index, item) {
                                            selectHtml +=
                                                '<option value="' +
                                                item.labelValue +
                                                '" >' +
                                                item.labelName +
                                                "</option>";
                                        });
                                        selectHtml += "</select>";
                                        return selectHtml;
                                    }
                                }, {
                                    field: "baseUnitQuantity",
                                    align: "center",
                                    title: "基础单位库存数",
                                    width: 140,
                                    edit: "text"
                                }, {
                                    field: "priceCurrency",
                                    align: "center",
                                    title: "计价币种",
                                    width: 200,
                                    templet: function(d) {
                                        let selectHtml =
                                            '<select lay-filter="priceCurrency-select" name="priceCurrency">';
                                        selectHtml += '<option value="" >请选择计价币种</option>';
                                        layui.each(priceCurrencyList, function(index, item) {
                                            selectHtml +=
                                                '<option value="' +
                                                item.labelValue +
                                                '" >' +
                                                item.labelName +
                                                "</option>";
                                        });
                                        selectHtml += "</select>";
                                        return selectHtml;
                                    }
                                }, {
                                    field: "selfProductStatus",
                                    align: "center",
                                    title: "是否自产产品",
                                    width: 200,
                                    templet: function(d) {
                                        let selectHtml =
                                            '<select lay-filter="selfProductStatus-select" name="selfProductStatus">';
                                        selectHtml +=
                                            '<option value="" >请选择是否自产产品</option>';
                                        layui.each(yesNoList, function(index, item) {
                                            selectHtml +=
                                                '<option value="' +
                                                item.labelValue +
                                                '" >' +
                                                item.labelName +
                                                "</option>";
                                        });
                                        selectHtml += "</select>";
                                        return selectHtml;
                                    }
                                }, {
                                    field: "purchasePrice",
                                    align: "center",
                                    title: "采购价",
                                    edit: "text"
                                }, {
                                    field: "sellStatus",
                                    align: "center",
                                    title: "是否可以销售",
                                    width: 200,
                                    templet: function(d) {
                                        let selectHtml =
                                            '<select lay-filter="sellStatus-select" name="sellStatus">';
                                        selectHtml +=
                                            '<option value="" >请选择是否自产产品</option>';
                                        layui.each(yesNoList, function(index, item) {
                                            selectHtml +=
                                                '<option value="' +
                                                item.labelValue +
                                                '" >' +
                                                item.labelName +
                                                "</option>";
                                        });
                                        selectHtml += "</select>";
                                        return selectHtml;
                                    }
                                }, {
                                    field: "price",
                                    align: "center",
                                    title: "单价",
                                    edit: "text"
                                }, {
                                    field: "taxRate",
                                    align: "center",
                                    title: "税率",
                                    edit: "text"
                                }, {
                                    field: "length",
                                    align: "center",
                                    title: "长度(mm)",
                                    edit: "text"
                                }, {
                                    field: "width",
                                    align: "center",
                                    title: "宽度(mm)",
                                    edit: "text"
                                }, {
                                    field: "height",
                                    align: "center",
                                    title: "高度(mm)",
                                    edit: "text"
                                }, {
                                    field: "weight",
                                    align: "center",
                                    title: "重量(克)",
                                    edit: "text"
                                }, {
                                    field: "supplierName",
                                    align: "center",
                                    title: "供应商"
                                }, {
                                    field: "customerProductName",
                                    align: "center",
                                    title: "客户品名",
                                    edit: "text"
                                }, {
                                    field: "customerMaterialNumber",
                                    align: "center",
                                    title: "客户料号",
                                    edit: "text"
                                }, {
                                    field: "customerSpecCode",
                                    align: "center",
                                    title: "客户规格码",
                                    edit: "text"
                                }, {
                                    field: "supplierProductName",
                                    align: "center",
                                    title: "供应商品名",
                                    edit: "text"
                                }, {
                                    field: "supplierMaterialNumber",
                                    align: "center",
                                    title: "供应商料号",
                                    edit: "text"
                                }, {
                                    field: "supplierSpecCode",
                                    align: "center",
                                    title: "供应商规格码",
                                    edit: "text"
                                }, {
                                    field: "safeStockValue",
                                    align: "center",
                                    title: "安全库存阈值",
                                    edit: "text"
                                }, {
                                    field: "purchaseCycle",
                                    align: "center",
                                    title: "采购周期(天)",
                                    edit: "text"
                                }, {
                                    field: "dullTimeValue",
                                    align: "center",
                                    title: "呆滞时长阈值(天)",
                                    width: 140,
                                    edit: "text"
                                }, {
                                    field: "warrantyDay",
                                    align: "center",
                                    title: "质保期(天)",
                                    edit: "text"
                                }, {
                                    field: "warrantyDueTime",
                                    align: "center",
                                    title: "质保到期时间",
                                    edit: "text"
                                }, {
                                    field: "dataSource",
                                    align: "center",
                                    title: "数据来源",
                                    edit: "text"
                                }, {
                                    field: "thingCodeName",
                                    align: "center",
                                    title: "是否一物一码",
                                    width: 200,
                                    templet: function(d) {
                                        let selectHtml =
                                            '<select lay-filter="thingCodeName-select" name="thingCodeName">';
                                        selectHtml +=
                                            '<option value="" >请选择是否一物一码</option>';
                                        layui.each(yesNoList, function(index, item) {
                                            selectHtml +=
                                                '<option value="' +
                                                item.labelValue +
                                                '" >' +
                                                item.labelName +
                                                "</option>";
                                        });
                                        selectHtml += "</select>";
                                        return selectHtml;
                                    }
                                }, {
                                    field: "batchName",
                                    align: "center",
                                    title: "是否批次管理",
                                    width: 200,
                                    templet: function(d) {
                                        let selectHtml =
                                            '<select lay-filter="batchName-select" name="batchName">';
                                        selectHtml +=
                                            '<option value="" >请选择是否批次管理</option>';
                                        layui.each(yesNoList, function(index, item) {
                                            selectHtml +=
                                                '<option value="' +
                                                item.labelValue +
                                                '" >' +
                                                item.labelName +
                                                "</option>";
                                        });
                                        selectHtml += "</select>";
                                        return selectHtml;
                                    }
                                }, {
                                    field: "inoutName",
                                    align: "center",
                                    title: "是否先进先出",
                                    width: 200,
                                    templet: function(d) {
                                        let selectHtml =
                                            '<select lay-filter="inoutName-select" name="inoutName">';
                                        selectHtml +=
                                            '<option value="" >请选择是否先进先出</option>';
                                        layui.each(yesNoList, function(index, item) {
                                            selectHtml +=
                                                '<option value="' +
                                                item.labelValue +
                                                '" >' +
                                                item.labelName +
                                                "</option>";
                                        });
                                        selectHtml += "</select>";
                                        return selectHtml;
                                    }
                                }]
                            ],
                            done: function(res, curr, count) {
                                $(".layui-table-body, .layui-table-box, .layui-table-cell").css(
                                    "overflow",
                                    "visible"
                                ); //显示高于表格
                            }
                        });

                        //监听单元格编辑
                        table.on("edit(productDetailAddTable)", function(obj) {
                            var value = obj.value, //得到修改后的值
                                data = obj.data, //得到所在行所有键值
                                field = obj.field; //得到字段
                            // layer.msg('[ID: ' + data.id + '] ' + field + ' 字段更改为：' + value);
                        });

                        form.on("submit(productAddSubmit)", function(data) {
                            var dataList = table.cache["productDetailAddTable"];
                            console.info(dataList, 9099);
                        });
                    }
                });
            }

            // 上传文件
            /*
             * _elem: 上传按钮的名字,
             * pathId: 显示图片容器的名字,
             * inputId: 提交文件路径元素的名字,
             * isMultiple: 是不是多文件(单文件为空或者false,多文件true)
             *
             * */
            function uploadImg(_elem, pathId, inputId, isMultiple) {
                upload.render({
                    elem: "#" + _elem,
                    url: config.upload_url + "upload",
                    data: {},
                    accept: "file",
                    exts: "jpg|png|RAR|zip|pdf|txt|doc|docx|xls|xlsx|ppt|pptx",
                    headers: {
                        Authorization: "Bearer " + config.getToken()
                    },
                    done: function(res) {
                        if (res.code == 200) {
                            layer.msg(res.msg || "上传成功", {
                                icon: 1
                            });
                            let imagUrl = res.data.url;
                            if (isMultiple == true) {
                                $("#" + pathId).append('<img src="' + imagUrl + '"/>');
                                $("#" + inputId).val(imagUrl);
                            } else {
                                $("#" + pathId).html('<img src="' + imagUrl + '"/>');
                                $("#" + inputId).val(imagUrl);
                            }
                        } else if (res.code == 502) {
                            return location.replace("admin/login.html");
                        } else {
                            layer.msg(res.msg || "上传失败", {
                                icon: 2
                            });
                        }
                    }
                });
            }

            // 渲染下拉选项
            function loadSelectHtml(data, tips, htmltarget, type, formName) {
                let html = " <option value>" + tips + "</option>";
                if (!data || data == null) {
                    return;
                }
                for (let i = 0; i < data.length; i++) {
                    if (type == 1) {
                        html += `<option value='${data[i].id}'>${data[i].name}</option>`;
                    }
                }
                $(
                    "form[lay-filter='" +
                    formName +
                    "'] select[name='" +
                    htmltarget +
                    "']"
                ).html(html);
                form.render("select");
            }

            // 模板下载
            $("#productDetailBtnTemplate").click(function() {
                window.location.href =
                    config.base + "enterprise/product/admin/productDetailWMS/template";
            });

            //导入excel
            $("#uploaderInput").on("change", function(e) {
                layer.load(2);
                var formData = new FormData();
                var files = e.target.files;
                let that = $(this);
                formData.append("file", files[0]);
                formData.append("name", files[0].name); //这个地方可以传递多个参数
                $.ajax({
                    url: config.base +
                        "enterprise/product/admin/productDetailWMS/importExcel",
                    data: formData,
                    headers: {
                        Authorization: "Bearer " + config.getToken()
                    },
                    type: "POST",
                    processData: false,
                    contentType: false,
                    success: function(res) {
                        layer.closeAll("loading");
                        if (res.code == 200) {
                            layer.msg(res.msg, {
                                icon: 1
                            });
                            layer.closeAll("page");
                            setTimeout((_) => {
                                location.reload();
                            }, 1000);
                        } else {
                            layer.msg(res.msg, {
                                icon: 2
                            });
                        }
                        that.val("");
                    }
                });
            });
        }
    );
</script>